﻿package com.esun.cheetah.view.personal.sportlotteryfootball;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Hashtable;

import com.esun.cheetah.R;

import com.esun.cheetah.biz.personal.personalcommunicater.sportlottery.SportteryFootballNoFilterAgainstInfoCommunicater;
import com.esun.cheetah.biz.personal.personalcommunicater.sportlottery.SportteryFootballRecommendAgainstInfoCommunicater;
import com.esun.cheetah.biz.personal.personalinfo.UserInfo;
import com.esun.cheetah.config.Config;
import com.esun.cheetah.config.Language;

import com.esun.cheetah.view.custom.CustomProgressDialog;
import com.esun.cheetah.view.custom.GridViewNoScroll;

import com.esun.cheetah.view.match.matchlist.adapter.FilterAdapter;

import com.esun.cheetah.view.personal.sportlotteryfootballinfo.SportteryFootballAgainstInfo;
import com.esun.cheetah.view.personal.sportlotteryfootballinfo.SportteryFootballLotteryInfo;

import com.esun.util.log.EDebug;

import android.app.Activity;
import android.app.Dialog;

import android.content.Context;

import android.content.Intent;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;

import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.animation.AnimationUtils;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.BaseExpandableListAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.ExpandableListView;

import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;

import android.widget.RadioGroup;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;
/**
 * 
 * @Package com.esun.cheetah.view.personal.sportlotteryfootball.SportteryFootballChooseList
 * @ClassName: SportteryFootballChooseList
 * @Description: TODO(SporlotteryFootballChooseList)
 * @author handy <br/>
 * @date create at 2012-7-31 下午2:56:08
 *
 */
public class SportteryFootballChooseList extends SportteryChooseList implements
		OnClickListener, OnScrollListener {
	private CustomProgressDialog progress;
	private Context context;
	// added by Kuroky 2012-08-06
	private Context mContext;
	private View view;
	private SportteryBuyLottery buyLotteryPage;
	private ImageButton fliterButton;
	private ImageButton kaijianginfoButton;

	private Button btnClean;
	private Button btnSubmit;
	private Button btnlogin;
	private Button btnRefresh;
	private ArrayList<Hashtable<String, Object>> listContent;
	private ArrayList<SportteryFootballAgainstInfo> listInfo;

	private RadioGroup rgTop;

	private ExpandableListView expandableListViewContent;
	private SportteryFootballExpandableListAdapter sportteryFootballExpandableListAdapter;

	private int type;

	private LinearLayout linearTitle;
	@SuppressWarnings("unused")
	private LinearLayout linearTitle1;
	private TextView tvDate;
	private TextView tvDay;
	private TextView tvSaishiCount;

	private ImageView imgExpand;

	private ArrayList<Boolean> saishiItemCheckedList;
	private SportteryFootballNoFilterAgainstInfoCommunicater sportteryFootballNoFilterAgainstInfoCommunicater;
	private SportteryFootballRecommendAgainstInfoCommunicater sportteryFootballRecommendAgainstInfoCommunicater;
	public static Handler handlerChoosePage;

	public static Handler sportteryFootballNoFilterAgainstInfoCommunicaterhandler;
	public static Handler sportteryFootballRecommendAgainstInfoCommunicaterHandler;

	private boolean isGettingTeamList = false;
	private boolean isUpdateAgainstList = false;
	private boolean isRecommend = false;
	private ArrayList<Object[]> listImageCache = new ArrayList<Object[]>();

	// private RelativeLayout progressdialogRefresh;

	private ImageListCache imageListCache = null;

	private ArrayList<View> alViewsList = new ArrayList<View>();

	// private int indicatorGroupId = -1;

	/** 2011-09-06 byCity 本地筛选工具 */
	AgainstTeamListLocalFilter againstTeamListLocalFilter;

	/** 获取视图 */
	public SportteryFootballChooseList(Context context, View view, Context mContext) {
		this.view = view;
		this.context = context;
		this.mContext = mContext ;
		
		init();
		initHandler();
		handlerInit();
		initCommunicater();
		refresh();
	}

	/**
	 * @title initCommunicater
	 * @description
	 */
	private void initCommunicater() {
		sportteryFootballRecommendAgainstInfoCommunicater = new SportteryFootballRecommendAgainstInfoCommunicater(
				sportteryFootballRecommendAgainstInfoCommunicaterHandler);
		sportteryFootballNoFilterAgainstInfoCommunicater = new SportteryFootballNoFilterAgainstInfoCommunicater(
				sportteryFootballNoFilterAgainstInfoCommunicaterhandler);

	}

	private void initHandler() {

		sportteryFootballNoFilterAgainstInfoCommunicaterhandler = new Handler() {

			@Override
			public void handleMessage(Message msg) {
				super.handleMessage(msg);
				switch (msg.what) {
				case Config.COMMUNICATER_SUCCESS:
					if (progress.isShowing()) {
						EDebug.o("dialog 消失....");
						progress.dismiss();
					}
					Message msgToGroup = SportteryFootballAgp.handlerSportteryFootballAgp
							.obtainMessage(SportteryFootballAgp.NO_FILTER, null);
					SportteryFootballAgp.handlerSportteryFootballAgp
							.sendMessage(msgToGroup);
					updateDialogFilter();
					// progressDialog.cancel();
					isUpdateAgainstList = false;
					getAgainstSucceed();
					break;
				case Config.COMMUNICATER_FAIL:
					if (progress.isShowing()) {
						EDebug.o("dialog 消失....");
						progress.dismiss();
					}

					EDebug.o("inithandler 1 通信异常");
					// progressDialog.cancel();
					break;
				case Config.COMMUNICATER_EXCEPTION:
					if (progress.isShowing()) {
						EDebug.o("dialog 消失....");
						progress.dismiss();
					}
					// btnRegist.setText("通讯异常");
					EDebug.o("inithandler 2  通信异常");
					// progressDialog.cancel();
					break;
				default:
					break;

				}
			}
		};

		sportteryFootballRecommendAgainstInfoCommunicaterHandler = new Handler() {
			@Override
			public void handleMessage(Message msg) {
				super.handleMessage(msg);
				switch (msg.what) {
				case Config.COMMUNICATER_SUCCESS:
					// Message msg = handlerChoosePage.obtainMessage(
					// GETRECOMMENDAGAINSTLIST_SUCCEED, null);
					// handlerChoosePage.sendMessage(msg);
					// Message msg1 =
					// handlerChoosePage.obtainMessage(GETRECOMMENDAGAINSTLIST_SUCCEED,
					// null);
					// handlerChoosePage.sendMessage(msg1);
					Message msgToGroup = SportteryFootballAgp.handlerSportteryFootballAgp
							.obtainMessage(SportteryFootballAgp.NO_FILTER, null);
					SportteryFootballAgp.handlerSportteryFootballAgp
							.sendMessage(msgToGroup);
					updateDialogFilter();
					isUpdateAgainstList = false;
					// getAgainstSucceed();
					getRecommendAgainstSucceed();
					if (progress.isShowing()) {
						EDebug.o("dialog 消失....");
						progress.dismiss();
					}
					// progressDialog.cancel();
					break;
				case Config.COMMUNICATER_FAIL:
					if (progress.isShowing()) {
						EDebug.o("dialog 消失....");
						progress.dismiss();
					}
					// progressDialog.cancel();

					break;
				case Config.COMMUNICATER_EXCEPTION:
					// tv_please_login.setText("通讯异常");
					// progressDialog.cancel();
					if (progress.isShowing()) {
						EDebug.o("dialog 消失....");
						progress.dismiss();
					}
					break;
				default:
					break;
				}
			}
		};

	}

	private void handlerInit() {
		handlerChoosePage = new Handler() {
			public void handleMessage(Message msg) {
				switch (msg.what) {
				case GETTEAMLIST_SUCCEED:
					isGettingTeamList = false;
					// sportteryFootballGetTeamListCommunicater.updateTeamInfo();
					EDebug.o(SportteryFootballChooseList.this, "获取联赛列表成功");
					Message msgToGroup = SportteryFootballAgp.handlerSportteryFootballAgp
							.obtainMessage(SportteryFootballAgp.NO_FILTER, null);
					SportteryFootballAgp.handlerSportteryFootballAgp
							.sendMessage(msgToGroup);
					updateDialogFilter();
					break;

				case LOG_SUCCEED:
					btnSubmit.setVisibility(View.VISIBLE);
 					btnlogin.setVisibility(View.GONE);
					break;

				case GETAGAINSTLIST_SUCCEED:
					isUpdateAgainstList = false;
					getAgainstSucceed();
					break;

				case GETRECOMMENDAGAINSTLIST_SUCCEED:
					isUpdateAgainstList = false;
					getRecommendAgainstSucceed();
					break;

				case DO_REFRESH:
					refresh();
					break;

				case DO_CLEAR:
					cleanListView();
					break;
					
				

				case DO_BACK_UPDATE:
					listContent.clear();
					listContent.addAll(SportteryFootballLotteryInfo
							.getSportteryFootballLotteryInfo().getLotterList());
					expandableListProcesForPageSwich();
					break;

				case GETAGAINSTLIST_FAIL:
					isUpdateAgainstList = false;
					sportteryFootballExpandableListAdapter
							.notifyDataSetChanged();
					linearTitle.setVisibility(View.INVISIBLE);
					// progressdialogRefresh.setVisibility(View.INVISIBLE);
					if (progress.isShowing()) {
						EDebug.o("dialog 消失....");
						progress.dismiss();
					}
					// ViewerUtil.showTipDialog(context,
					// sportteryFootballNoFilterAgainstInfoCommunicater
					// .getServerMsg(), false);
					Toast.makeText(
							context,
							sportteryFootballNoFilterAgainstInfoCommunicater
									.getServerMsg(), 500).show();
					break;

				case GETRECOMMENDAGAINSTLIST_FAIL:

					isUpdateAgainstList = false;
					listGroup.clear();
					listChild.clear();
					sportteryFootballExpandableListAdapter
							.notifyDataSetChanged();
					linearTitle.setVisibility(View.INVISIBLE);
					// progressdialogRefresh.setVisibility(View.INVISIBLE);
					if (progress.isShowing()) {
						EDebug.o("dialog 消失....");
						progress.dismiss();
					}
					// ViewerUtil.showTipDialog(context,
					// sportteryFootballRecommendAgainstInfoCommunicater
					// .getServerMsg(), false);
					Toast.makeText(
							context,
							sportteryFootballRecommendAgainstInfoCommunicater
									.getServerMsg(), 500).show();
					break;

				case GETTEAMLIST_FAIL:

					// isGettingTeamList = false;
					// progressdialogRefresh.setVisibility(View.INVISIBLE);
					// // ViewerUtil.showTipDialog(context,
					// // sportteryFootballGetTeamListCommunicater
					// .getServerMsg(), false);
					break;

				case Config.CONNECTION_FAIL:

					sportteryFootballExpandableListAdapter
							.notifyDataSetChanged();
					linearTitle.setVisibility(View.INVISIBLE);
					isUpdateAgainstList = false;
					// progressdialogRefresh.setVisibility(View.INVISIBLE);
					if (progress.isShowing()) {
						EDebug.o("dialog 消失....");
						progress.dismiss();
					}
					// ViewerUtil.showTipDialog(context,
					// Language.STR_CONNECTIONFAIL, false);
					Toast.makeText(context, Language.STR_CONNECTIONFAIL, 500)
							.show();
					break;

				case GETTEAMLIST_CONNECTION_FAIL:

					isGettingTeamList = false;
					// progressdialogRefresh.setVisibility(View.INVISIBLE);
					if (progress.isShowing()) {
						EDebug.o("dialog 消失....");
						progress.dismiss();
					}
					// ViewerUtil.showTipDialog(context,
					// Language.STR_CONNECTIONFAIL, false);
					Toast.makeText(context, Language.STR_CONNECTIONFAIL, 500)
							.show();
					break;

				case DO_FILTER:

					showDialogFilter();
					break;

				case GET_IMAGECACHE_SUCCEED:

					// pdTest.cancel();

					if (imageListCache == null) {
						EDebug.o(SportteryFootballChooseList.this, "加载触发,走你");
						EDebug.o(SportteryFootballChooseList.class,
								" creat object !!" + listImageCache.size());
						imageListCache = new ImageListCache(context,
								listImageCache);
					} else {
						EDebug.o(SportteryFootballChooseList.this, "重加载触发,走你");
						imageListCache.addToLine(listImageCache);
					}

					if (scrollViewFilter != null) {
						EDebug.o(SportteryFootballChooseList.this,
								"线程触发,scrollto 0");
						scrollViewFilter.scrollTo(0, 0);
					}
					break;

				default:
					break;
				}
			}

		};
	}

	private void updateDialogFilter() {
		// boolean 列表,存放checkbox状态
		saishiItemCheckedList.clear();
		// String 选中的联赛名称
		listSelectedLeagueNmae.clear();
		// View 缓存adapter中的view
		alViewsList.clear();
		// object[] 调用图片加载
		listImageCache.clear();
		if (imageListCache != null) {
			imageListCache = null;
		}
		for (int i = 0; i < SportteryFootballLotteryInfo
				.getSportteryFootballLotteryInfo().getSimpleLeagueList().size(); i++) {
			saishiItemCheckedList.add((Boolean) SportteryFootballLotteryInfo
					.getSportteryFootballLotteryInfo().getSimpleLeagueList()
					.get(i).get(IS_CHECKED));
			listSelectedLeagueNmae.add((String) SportteryFootballLotteryInfo
					.getSportteryFootballLotteryInfo().getSimpleLeagueList()
					.get(i).get(NAME));
		}
	}

	/** 重点方法 开始更新各种信息 */
	private void getAgainstSucceed() {
		try {
			// progressdialogRefresh.setVisibility(View.INVISIBLE);
			if (progress.isShowing()) {
				EDebug.o("dialog 消失....");
				progress.dismiss();
			}
		} catch (Exception e) {
			EDebug.o(SportteryFootballChooseList.this, e.toString());
		}
		updateFilterInfo();

		listInfo.clear();
		listInfo.addAll(sportteryFootballNoFilterAgainstInfoCommunicater
				.getAgainstInfoList());
		sortListInfo();
		updateListContent();
		updateListExpandadble(listContent, true);
		sportteryFootballExpandableListAdapter.notifyDataSetChanged();

		updateTitleView(0);
		for (int i = 0; i < listGroup.size(); i++)
			expandableListViewContent.expandGroup(i);

		filterOutdated = true;
		fliterButton
				.setBackgroundResource(R.drawable.btn_lotterychoose_filter_style);
	}

	private void updateFilterInfo() {
		filterOutdated = true;
		final String[] allLeagues = sportteryFootballNoFilterAgainstInfoCommunicater
				.getLeagueNames();

		selectedLeagues.clear();
		if (allLeagues != null) {
			for (String league : allLeagues) {
				selectedLeagues.add(league);
			}
		}

		rangqiuType = 0;
	}

	private void getRecommendAgainstSucceed() {
		// progressdialogRefresh.setVisibility(View.INVISIBLE);
		if (progress.isShowing()) {
			EDebug.o("dialog 消失....");
			progress.dismiss();
		}
		updateFilterInfo();
		listInfo.clear();
		listInfo.addAll(sportteryFootballRecommendAgainstInfoCommunicater
				.getAgainstInfoList());
		sortListInfo();
		updateListContent();
		updateListExpandadble(listContent, true);
		sportteryFootballExpandableListAdapter.notifyDataSetChanged();

		updateTitleView(0);
		for (int i = 0; i < listGroup.size(); i++)
			expandableListViewContent.expandGroup(i);

		filterOutdated = true;
		fliterButton
				.setBackgroundResource(R.drawable.btn_lotterychoose_filter_style);
	}

	public View getView() {
		((SportteryChooseActivity) context).setCurrentPageFlag(0);
		Message msg = SportteryFootballAgp.handlerSportteryFootballAgp
				.obtainMessage(SportteryFootballAgp.IN_CHOOSE_VIEW, null);
		SportteryFootballAgp.handlerSportteryFootballAgp.sendMessage(msg);
		return view;
	}

	private void refresh() {
		if (canCommunicate()) {
			// progressdialogRefresh.setVisibility(View.VISIBLE);
			progress = new CustomProgressDialog(mContext);
			progress.setMessage("加载数据中...");
			progress.show();
			progress.setCancelable(true);
			type = 2;
			rangqiuType = 0;

			if (isRecommend) {

				sportteryFootballRecommendAgainstInfoCommunicater
						.startCommunicate();
				EDebug.o("isRecommend ---------------------");

				// threadRecommendAgainst();
			} else {

				sportteryFootballNoFilterAgainstInfoCommunicater
						.startCommunicate();
				EDebug.o("all ---------------------");
				// threadAgainst();
			}
			// threadGetTeamList();
		} else {
			EDebug.o(SportteryFootballChooseList.this, " 通信中..");
		}
	}

	private void init() {

		btnClean = (Button) view
				.findViewById(R.id.sportteryfootballchooseact_btn_clean);
		btnSubmit = (Button) view
				.findViewById(R.id.sportteryfootballchooseact_btn_submit);
		btnlogin = (Button) view
				.findViewById(R.id.sportteryfootballchooseact_btn_login);
		if (UserInfo.getUserInfo().getCk().length() < 3) {
			btnSubmit.setVisibility(View.GONE);
			btnlogin.setVisibility(View.VISIBLE);
		} else {
			btnSubmit.setVisibility(View.VISIBLE);
			btnlogin.setVisibility(View.GONE);
		}
		btnRefresh = (Button) view
				.findViewById(R.id.sportteryfootballchooseact_btn_refresh);

		fliterButton = (ImageButton) view
				.findViewById(R.id.sportterybasketballagp_btn_filter);
		fliterButton.setOnClickListener(this);
		kaijianginfoButton = (ImageButton) view
				.findViewById(R.id.sportteryfootballagp_btn_kaijiang);
		kaijianginfoButton.setOnClickListener(this);

		btnClean.setOnClickListener(this);
		btnSubmit.setOnClickListener(this);
		btnlogin.setOnClickListener(this);
		btnRefresh.setOnClickListener(this);

		listContent = new ArrayList<Hashtable<String, Object>>();
		listInfo = new ArrayList<SportteryFootballAgainstInfo>();

		// sportteryFootballNoFilterAgainstInfoCommunicater = new
		// SportteryFootballNoFilterAgainstInfoCommunicater(
		// sportteryFootballNoFilterAgainstInfoCommunicaterhandler);
		// sportteryFootballRecommendAgainstInfoCommunicater = new
		// SportteryFootballRecommendAgainstInfoCommunicater(
		// sportteryFootballRecommendAgainstInfoCommunicaterHandler);

		expandableListViewContent = (ExpandableListView) view
				.findViewById(R.id.sportteryfootballchooseact_expandalblelistview_content);
		sportteryFootballExpandableListAdapter = new SportteryFootballExpandableListAdapter(
				context);
		expandableListViewContent
				.setAdapter(sportteryFootballExpandableListAdapter);
		expandableListViewContent.setOnScrollListener(this);

		for (int i = 0; i < listInfo.size(); i++) {
			EDebug.o(SportteryFootballChooseList.this, listInfo.get(i)
					.getDate());
		}
		for (int i = 0; i < listContent.size(); i++) {
			EDebug.o(SportteryFootballChooseList.this, "is title = "
					+ listContent.get(i).get(IS_TITLE));
		}
		// 赛事选择列表初始化
		saishiItemCheckedList = new ArrayList<Boolean>();

		linearTitle = (LinearLayout) view
				.findViewById(R.id.sportteryfootballchooseact_linear_title);
		linearTitle1 = (LinearLayout) view
				.findViewById(R.id.sportteryfootballchooseact_linear_title1);
		tvDate = (TextView) view
				.findViewById(R.id.sportteryfootballchooseact_tv_date);
		tvSaishiCount = (TextView) view
				.findViewById(R.id.sportteryfootballchooseact_tv_mtachCount);
		tvDay = (TextView) view
				.findViewById(R.id.sportteryfootballchooseact_tv_day);

		imgExpand = (ImageView) view
				.findViewById(R.id.sportteryfootballchooseact_img_expand);
		linearTitle.setVisibility(View.GONE);

		// progressdialogRefresh = (RelativeLayout) view
		// .findViewById(R.id.sportteryfootball_relative_progress);
		SportteryFootballLotteryInfo.getSportteryFootballLotteryInfo()
				.getAllLeagueList().clear();
		SportteryFootballLotteryInfo.getSportteryFootballLotteryInfo()
				.getRecommendLeagueList().clear();
		initRadioGroupTop();

	}

	private void initRadioGroupTop() {
		rgTop = (RadioGroup) view
				.findViewById(R.id.sportteryfootballchooseact_rg_top);
		rgTop.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(RadioGroup group, int checkedId) {
				switch (checkedId) {

				case R.id.sportteryfootballchooseact_rb_all:
					isRecommend = false;
					SportteryFootballLotteryInfo
							.getSportteryFootballLotteryInfo()
							.getRecommendLeagueList().clear();
					SportteryFootballLotteryInfo
							.getSportteryFootballLotteryInfo()
							.getRecommendLeagueList().addAll(listContent);
					listContent.clear();
					if (SportteryFootballLotteryInfo
							.getSportteryFootballLotteryInfo()
							.getAllLeagueList().isEmpty()) {
						listGroup.clear();
						listChild.clear();
						refresh();
					} else {
						listContent.addAll(SportteryFootballLotteryInfo
								.getSportteryFootballLotteryInfo()
								.getAllLeagueList());
						expandableListProcesForPageSwich();
					}
					break;

				case R.id.sportteryfootballchooseact_rb_recommend:
					isRecommend = true;
					SportteryFootballLotteryInfo
							.getSportteryFootballLotteryInfo()
							.getAllLeagueList().clear();
					SportteryFootballLotteryInfo
							.getSportteryFootballLotteryInfo()
							.getAllLeagueList().addAll(listContent);
					listContent.clear();
					if (SportteryFootballLotteryInfo
							.getSportteryFootballLotteryInfo()
							.getRecommendLeagueList().isEmpty()) {
						listGroup.clear();
						listChild.clear();
						refresh();
					} else {
						listContent.addAll(SportteryFootballLotteryInfo
								.getSportteryFootballLotteryInfo()
								.getRecommendLeagueList());
						expandableListProcesForPageSwich();
					}
					break;

				default:
					break;
				}
			}
		});
	}

	/**
	 * 页面切换时expandablelistview的处理, 筛选显示, adapter加载, scrollview滚至最上,
	 * 更新titlebar显示, 展开每一条group
	 */

	private void expandableListProcesForPageSwich() {
		if (listSelectedLeagueNmae.isEmpty()) {
			updateListExpandadble(listContent, true);
		} else {
			updateListExpandadble(listContent, false);
		}
		sportteryFootballExpandableListAdapter.notifyDataSetChanged();
		expandableListViewContent.setSelectedGroup(0);
		updateTitleView(0);
		for (int i = 0; i < listGroup.size(); i++)
			expandableListViewContent.expandGroup(i);
	}

	private boolean canCommunicate() {
		boolean b;
		if (!isGettingTeamList && !isUpdateAgainstList) {
			b = true;
		} else {
			b = false;
		}
		return b;
	}

	/**
	 * 判断是否添加新的expend
	 */

	private void updateListContent() {
		int titleTaget = 0; // title在列表中的位置
		int itemCount = 1; // 相同title下元素个数
		if (listInfo.size() > 0) {
			listContent.clear();
			listContent.add(tableInListContentIsTitle(0, itemCount));

			listContent.add(tableInListContentNotTitle(0));

			for (int i = 1; i < listInfo.size(); i++) {
				if (listInfo.get(i).getDate()
						.equals(listInfo.get(i - 1).getDate())) {
					listContent.add(tableInListContentNotTitle(i));
					itemCount++;
					listContent.get(titleTaget).put(ITEM_COUNT, itemCount);

				} else {
					EDebug.o(SportteryFootballChooseList.this, "date is "
							+ listInfo.get(i).getDate());
					EDebug.o(SportteryFootballChooseList.this,
							"date before is " + listInfo.get(i - 1).getDate());
					itemCount = 1;
					titleTaget = listContent.size();
					EDebug.o(SportteryFootballChooseList.this,
							"title taget is " + titleTaget);
					listContent.add(tableInListContentIsTitle(i, itemCount));
					listContent.add(tableInListContentNotTitle(i));
				}
			}
		} else {
			listContent.clear();
		}
	}

	private String POSITION = "position";

	/** 更新expend列表内容 */
	private void updateListExpandadble(
			ArrayList<Hashtable<String, Object>> list, boolean isAll) {
		Log.e("Filter", "UpdateListExpandable");

		againstTeamListLocalFilter = new AgainstTeamListLocalFilter(list);
		againstTeamListLocalFilter.getResult(rangqiuType, selectedLeagues);
		listChild.clear();
		listGroup.clear();
		listChildView.clear();
		for (int i = 0; i < list.size(); i++) {
			if ((Boolean) list.get(i).get(IS_TITLE)) {
				listGroup.add(list.get(i));
				ArrayList<Hashtable<String, Object>> listChild_ = new ArrayList<Hashtable<String, Object>>();
				listChild.add(listChild_);
				ArrayList<View> listChildView_ = new ArrayList<View>();
				listChildView.add(listChildView_);
			} else if ((Boolean) list.get(i).get(IS_SHOW)) {
				list.get(i).put(POSITION, i);
				listChild.get(listChild.size() - 1).add(list.get(i));
			} else {
				list.get(i).put(POSITION, i);
			}
		}
		for (int i = 0; i < listGroup.size(); i++) {
			listGroup.get(i).put(ITEM_COUNT, listChild.get(i).size());
		}
	}

	private static final String IS_DAN = "is_dan";
	private static final String IS_SHOW = "is_show";

	private Hashtable<String, Object> tableInListContentNotTitle(int position) {
		Hashtable<String, Object> hashtable = new Hashtable<String, Object>();
		hashtable.put(INFO, listInfo.get(position));
		hashtable.put(IS_TITLE, false);
		hashtable.put(W, false);
		hashtable.put(D, false);
		hashtable.put(L, false);
		hashtable.put(IS_ACTIVE, false);
		hashtable.put(IS_DAN, false);
		hashtable.put(IS_SHOW, true);
		return hashtable;
	}

	
	private Hashtable<String, Object> tableInListContentIsTitle(int position,
			int itemCount) {
		Hashtable<String, Object> hashtable = new Hashtable<String, Object>();
		hashtable.put(ITEM_COUNT, itemCount);
		hashtable.put(IS_TITLE, true);
		hashtable.put(DATE, listInfo.get(position).getDate());
		hashtable.put(DAY_OF_WEEK, listInfo.get(position).getWeek());
		hashtable.put(IS_ACTIVE, false);
		hashtable.put(IS_DAN, false);
		hashtable.put(IS_SHOW, true);
		return hashtable;
	}

	@Override
	public void onClick(View v) {

		if (isGettingTeamList) {
			Toast.makeText(context, "信息加载中...", Toast.LENGTH_SHORT).show();
		} else {
			switch (v.getId()) {

			case R.id.sportteryfootballchooseact_btn_refresh:
				Message msg = handlerChoosePage.obtainMessage(DO_REFRESH, null);
				handlerChoosePage.sendMessage(msg);
				break;
			case R.id.sportterybasketballagp_btn_filter:
				Message msg1 = handlerChoosePage.obtainMessage(DO_FILTER, null);
				handlerChoosePage.sendMessage(msg1);
				break;
			case R.id.sportteryfootballagp_btn_kaijiang:

				Intent kaijiangIntent = new Intent();
				kaijiangIntent.setClass(context, LotteryInfoListFootball.class);
				((Activity) context).startActivity(kaijiangIntent);
				// Intent sporthelpIntent = new Intent();
				// sporthelpIntent.setClass(context,
				// SportteryFootbalHelp.class);
				// ((Activity) context).startActivity(sporthelpIntent);
				break;

			case R.id.sportteryfootballchooseact_btn_clean:
				cleanListView();
				break;

			case R.id.sportteryfootballchooseact_btn_submit:
				if (getActiveTeamCount() < getLimitEventCount()) {
					// ViewerUtil.showTipDialog(context, "最少选择"
					// + getLimitEventCount() + "场比赛", false);
					Toast.makeText(context,
							"最少选择" + getLimitEventCount() + "场比赛", 500).show();
					// } else if (UserInfo.getUserInfo().getCk().length() < 3) {
					// Intent intent = new Intent();
					// intent.setClass(context, LoginBetAct.class);
					// ((Activity) context).startActivity(intent);
				} else {
					SportteryFootballLotteryInfo
							.getSportteryFootballLotteryInfo().getLotterList()
							.clear();
					SportteryFootballLotteryInfo
							.getSportteryFootballLotteryInfo().getLotterList()
							.addAll(listContent);
					((Activity) context).setContentView(buyLotteryPage
							.getView());
				}
				break;
			case R.id.sportteryfootballchooseact_btn_login:
				// showLogin();
				Intent intent = new Intent();
				intent.setClass(context, LoginBetAct.class);
				intent.putExtra("flag", "1");  
				((Activity) context).startActivity(intent);
				break;

			default:
				break;
			}
		}
	}

	private int getLimitEventCount() {
		int i = 0;
		if (type == 1) {
			i = 1;
		} else if (type == 2) {
			i = 2;
		}
		return i;
	}

	private void cleanListView() {

		for (int i = 0; i < listContent.size(); i++) {
			if (!(Boolean) listContent.get(i).get(IS_TITLE)) {
				listContent.get(i).put(W, false);
				listContent.get(i).put(D, false);
				listContent.get(i).put(L, false);
				listContent.get(i).put(IS_ACTIVE, false);
				listContent.get(i).put(IS_DAN, false);
			}
		}
		updateListExpandadble(listContent, false);
		sportteryFootballExpandableListAdapter.notifyDataSetChanged();
	}

	/**
	 * @Title: sortListInfo
	 * @Description: TODO(对返回列表进行日期排序)
	 * @param: 设定文件
	 * @return: void 返回类型
	 * @throws
	 */

	@SuppressWarnings({ "rawtypes", "unchecked" })
	private void sortListInfo() {
		Collections.sort(listInfo, new Comparator() {
			@Override
			public int compare(Object object1, Object object2) {
				SportteryFootballAgainstInfo sa1 = (SportteryFootballAgainstInfo) object1;
				SportteryFootballAgainstInfo sa2 = (SportteryFootballAgainstInfo) object2;
				int i = (sa1.getDate()).compareTo(sa2.getDate());
				return i;
			}
		});

	}

	private void updateTableLottery(int position, boolean w, boolean d,
			boolean l, CheckBox cbx, String key,
			SportteryFootballAgainstInfo sportteryFootballAgainstInfo) {
		boolean isChecked = false;
		if (key.equals(W)) {
			isChecked = w;
		} else if (key.equals(D)) {
			isChecked = d;
		} else if (key.equals(L)) {
			isChecked = l;
		} else {
			EDebug.o(SportteryFootballChooseList.this, "sun your sister ...");
		}
		if (getActiveTeamCount() > getMaxTeamNum() - 1
				&& !(Boolean) listContent.get(position).get(IS_ACTIVE)) {
			cbx.setChecked(false);
			Toast.makeText(context, "最多选择" + getMaxTeamNum() + "场比赛",
					Toast.LENGTH_SHORT).show();
		} else {
			listContent.get(position).put(key, isChecked);
			listContent.get(position).put(IS_ACTIVE, true);

			if (!w && !d && !l) {
				listContent.get(position).put(IS_ACTIVE, false);
			}
		}
	}

	private int getActiveTeamCount() {
		int activeTeamCount = 0;
		for (int i = 0; i < listContent.size(); i++) {
			if ((Boolean) listContent.get(i).get("is_active")) {
				activeTeamCount++;
			}
		}
		return activeTeamCount;
	}

	class TeamListAdapter extends BaseAdapter {
		private LayoutInflater listInflater;
		private boolean scroll = true;

		public TeamListAdapter(Context context) {
			this.listInflater = LayoutInflater.from(context);
		}

		@Override
		public int getCount() {
			return saishiItemCheckedList.size();
		}

		@Override
		public Object getItem(int position) {
			return null;
		}

		@Override
		public long getItemId(int position) {
			return position;
		}

		@Override
		public View getView(final int position, View convertView,
				ViewGroup parent) {

			if (scrollViewFilter != null && scroll) {
				EDebug.o(SportteryFootballChooseList.this,
						"adapter触发,scrollto 0");
				scrollViewFilter.scrollTo(0, 0);
				scroll = false;
			}
			if (convertView == null
					&& alViewsList.size() < saishiItemCheckedList.size()) {
				convertView = (RelativeLayout) listInflater.inflate(
						R.layout.sportteryfootball_dialog_saishi_item, null);
				// }

				ImageView img = (ImageView) convertView
						.findViewById(R.id.sportteryfootballdialogsaishiitem_img_item);
				img.setTag(position);
				Object[] objs = {
						(String) SportteryFootballLotteryInfo
								.getSportteryFootballLotteryInfo()
								.getSimpleLeagueList().get(position)
								.get(IMAGE_ID), img };

				if (listImageCache.size() < saishiItemCheckedList.size()) {
					listImageCache.add(objs);
					EDebug.o(SportteryFootballChooseList.this,
							"添加item & the size is " + listImageCache.size());
					if (listImageCache.size() == saishiItemCheckedList.size()) {
						Message msg = handlerChoosePage.obtainMessage(
								GET_IMAGECACHE_SUCCEED, null);
						handlerChoosePage.sendMessage(msg);
					}
				}
				CheckBox cbxItem = (CheckBox) convertView
						.findViewById(R.id.sportteryfootballdialogsaishiitem_cbx_item);
				// cbxItem.setText((String) SportteryFootballLotteryInfo
				// .getSportteryFootballLotteryInfo()
				// .getSimpleLeagueList().get(position).get(SAISHI_NAME));
				cbxItem.setText((String) SportteryFootballLotteryInfo
						.getSportteryFootballLotteryInfo()
						.getSimpleLeagueList().get(position).get(NAME));
				cbxItem.setChecked(true);
				OnCheckedChangeListener onCheckedChangeListener = new OnCheckedChangeListener() {

					@Override
					public void onCheckedChanged(CompoundButton buttonView,
							boolean isChecked) {
						saishiItemCheckedList.set(position, isChecked);
					}
				};
				cbxItem.setOnCheckedChangeListener(onCheckedChangeListener);
				alViewsList.add(convertView);
			}
			return alViewsList.get(position);
		}
	}

	/** 判断最大场次 */
	private int getMaxTeamNum() {
		int i = 0;
		if (type == 1) {
			i = 8;
		} else if (type == 2) {
			i = 15;
		} else {
			EDebug.o(SportteryFootballChooseList.this, "玩法出错");
		}
		EDebug.o(SportteryFootballChooseList.this, "max team num is " + i);
		return i;
	}

	private ArrayList<ArrayList<Hashtable<String, Object>>> listChild = new ArrayList<ArrayList<Hashtable<String, Object>>>();
	private ArrayList<Hashtable<String, Object>> listGroup = new ArrayList<Hashtable<String, Object>>();
	private ArrayList<ArrayList<View>> listChildView = new ArrayList<ArrayList<View>>();

	/**
	 * 
	 * @Package com.esun.cheetah.view.personal.sportlotteryfootball.SportteryFootballExpandableListAdapter
	 * @ClassName: SportteryFootballExpandableListAdapter
	 * @Description: TODO(set content of expend list )
	 * @author handy <br/>
	 * @date create at 2012-8-2 上午11:36:00
	 *
	 */

	class SportteryFootballExpandableListAdapter extends
			BaseExpandableListAdapter {
		private LayoutInflater listInflater;

		public SportteryFootballExpandableListAdapter(Context context) {
			this.listInflater = LayoutInflater.from(context);
		}

		@Override
		public Object getChild(int groupPosition, int childPosition) {
			return listChild.get(groupPosition).get(childPosition);
		}

		@Override
		public long getChildId(int groupPosition, int childPosition) {
			return childPosition;
		}

		@Override
		public View getChildView(int groupPosition, int childPosition,
				boolean isLastChild, View convertView, ViewGroup parent) {
			if (convertView == null) {
				EDebug.o(SportteryFootballChooseList.this, "新建view "
						+ childPosition);
				convertView = (RelativeLayout) listInflater.inflate(
						R.layout.sportteryfootball_choose_item1, null);
			}
			final SportteryFootballAgainstInfo sportteryFootballAgainstInfo = (SportteryFootballAgainstInfo) listChild
					.get(groupPosition).get(childPosition).get(INFO);
			((TextView) convertView
					.findViewById(R.id.sportteryfootballchooseitem_tv_homeName))
					.setText(sportteryFootballAgainstInfo.getHomesxname());
			((TextView) convertView
					.findViewById(R.id.sportteryfootballchooseitem_tv_visiterName))
					.setText(sportteryFootballAgainstInfo.getAwaysxname());
			((TextView) convertView
					.findViewById(R.id.sportteryfootballchooseitem_tv_leagueName))
					.setText(sportteryFootballAgainstInfo.getSimpleleague());
			((TextView) convertView
					.findViewById(R.id.sportteryfootballchooseitem_tv_rangqiu))
					.setText(sportteryFootballAgainstInfo.getRangqiu());
			String strPtggEndTime = sportteryFootballAgainstInfo.getEndtime()
					.substring(10, 16);
			// String strPtggEndTime = "1123";

			((TextView) convertView
					.findViewById(R.id.tv_match_list_score_item_host_team_number))
					.setText(sportteryFootballAgainstInfo.getHomestanding());
			((TextView) convertView
					.findViewById(R.id.tv_match_list_score_item_guest_team_number))
					.setText(sportteryFootballAgainstInfo.getAwaystanding());

			((TextView) convertView
					.findViewById(R.id.sportteryfootballchooseitem_tv_ptggEndTime))
					.setText(strPtggEndTime);

			((TextView) convertView
					.findViewById(R.id.sportteryfootballchooseitem_cbx_WT))
					.setText(sportteryFootballAgainstInfo.getWin().toString());
			((TextView) convertView
					.findViewById(R.id.sportteryfootballchooseitem_cbx_DT))
					.setText(sportteryFootballAgainstInfo.getDraw().toString());
			((TextView) convertView
					.findViewById(R.id.sportteryfootballchooseitem_cbx_LT))
					.setText(sportteryFootballAgainstInfo.getLost().toString());

			final CheckBox cbxW = (CheckBox) convertView
					.findViewById(R.id.sportteryfootballchooseitem_cbx_W);
			final CheckBox cbxD = (CheckBox) convertView
					.findViewById(R.id.sportteryfootballchooseitem_cbx_D);
			final CheckBox cbxL = (CheckBox) convertView
					.findViewById(R.id.sportteryfootballchooseitem_cbx_L);

			final int position = (Integer) listChild.get(groupPosition)
					.get(childPosition).get(POSITION);
			OnCheckedChangeListener onCheckedChangeListener = new OnCheckedChangeListener() {

				@Override
				public void onCheckedChanged(CompoundButton buttonView,
						boolean isChecked) {
					switch (buttonView.getId()) {
					case R.id.sportteryfootballchooseitem_cbx_W:
						updateTableLottery(position, isChecked,
								cbxD.isChecked(), cbxL.isChecked(), cbxW, W,
								sportteryFootballAgainstInfo);
						break;

					case R.id.sportteryfootballchooseitem_cbx_D:
						updateTableLottery(position, cbxW.isChecked(),
								isChecked, cbxL.isChecked(), cbxD, D,
								sportteryFootballAgainstInfo);
						break;

					case R.id.sportteryfootballchooseitem_cbx_L:
						updateTableLottery(position, cbxW.isChecked(),
								cbxD.isChecked(), isChecked, cbxL, L,
								sportteryFootballAgainstInfo);
						break;

					default:
						break;
					}

				}
			};
			cbxW.setOnCheckedChangeListener(onCheckedChangeListener);
			cbxD.setOnCheckedChangeListener(onCheckedChangeListener);
			cbxL.setOnCheckedChangeListener(onCheckedChangeListener);

			cbxW.setChecked((Boolean) listChild.get(groupPosition)
					.get(childPosition).get(W));
			cbxD.setChecked((Boolean) listChild.get(groupPosition)
					.get(childPosition).get(D));
			cbxL.setChecked((Boolean) listChild.get(groupPosition)
					.get(childPosition).get(L));

			cbxW.setText("胜");
			// + sportteryFootballAgainstInfo.getWin());
			cbxD.setText("平");
			// + sportteryFootballAgainstInfo.getDraw());
			cbxL.setText("负");
			// + sportteryFootballAgainstInfo.getLost());
			EDebug.o("sportteryFootballAgainstInfo.getWin()--- "
					+ sportteryFootballAgainstInfo.getWin());

			return convertView;
		}

		@Override
		public int getChildrenCount(int groupPosition) {
			return listChild.get(groupPosition).size();
		}

		@Override
		public Object getGroup(int groupPosition) {
			return listGroup.get(groupPosition);
		}

		@Override
		public int getGroupCount() {

			return listGroup.size();
		}

		@Override
		public long getGroupId(int groupPosition) {
			return groupPosition;
		}

		@Override
		public View getGroupView(int groupPosition, boolean isExpanded,
				View convertView, ViewGroup parent) {

			if (convertView == null) {
				convertView = (LinearLayout) listInflater.inflate(
						R.layout.sportteryfootball_choose_item_title1, null);
			}
			((TextView) convertView
					.findViewById(R.id.sportteryfootballchooseact_tv_date))
					.setText((String) listGroup.get(groupPosition).get(DATE));
			((TextView) convertView
					.findViewById(R.id.sportteryfootballchooseact_tv_day))
					.setText((String) listGroup.get(groupPosition).get(
							DAY_OF_WEEK));
			((TextView) convertView
					.findViewById(R.id.sportteryfootballchooseact_tv_mtachCount))
					.setText(Integer.toString((Integer) listGroup.get(
							groupPosition).get(ITEM_COUNT)));
			ImageView imgExpand = (ImageView) convertView
					.findViewById(R.id.sportteryfootballchooseact_img_expand);
			if (isExpanded) {
				imgExpand.setBackgroundResource(R.drawable.icon_default_packup);
			} else {
				imgExpand.setBackgroundResource(R.drawable.icon_default_unfold);
			}
			return convertView;
		}

		@Override
		public boolean hasStableIds() {
			return false;
		}

		@Override
		public boolean isChildSelectable(int groupPosition, int childPosition) {

			return false;
		}

		@Override
		public boolean areAllItemsEnabled() {
			return true;
		}

		public void hideGroup(int groupPos) {

		}
	}

	@Override
	public void onScroll(AbsListView view, int firstVisibleItem,
			int visibleItemCount, int totalItemCount) {

		ExpandableListView listView = (ExpandableListView) view;

		/**
		 * calculate point (0,0)
		 */
		int npos = view.pointToPosition(0, 0);
		long pos = listView.getExpandableListPosition(npos);
		int childPos = ExpandableListView.getPackedPositionChild(pos);
		int groupPos = ExpandableListView.getPackedPositionGroup(pos);
		if (npos != AdapterView.INVALID_POSITION) {
			if (childPos == listChild.get(groupPos).size() - 1) {

				linearTitle.setAnimation(AnimationUtils.loadAnimation(context,
						R.anim.fade));
				linearTitle.setVisibility(View.GONE);
			} else {
				updateTitleView(groupPos);
			}
			if (childPos == AdapterView.INVALID_POSITION) {

				updateTitleView(groupPos);

			}
		}
	}

	/** 更新layout title */
	private void updateTitleView(final int groupPos) {
		linearTitle.setVisibility(View.GONE);
		if (!listGroup.isEmpty()) {
			tvDate.setText((String) listGroup.get(groupPos).get(DATE));
			tvDay.setText((String) listGroup.get(groupPos).get(DAY_OF_WEEK));
			EDebug.o(SportteryFootballChooseList.this, "item count is "
					+ listGroup.get(groupPos).get(ITEM_COUNT));
			tvSaishiCount.setText(Integer.toString((Integer) listGroup.get(
					groupPos).get(ITEM_COUNT)));
		} else {
			linearTitle.setVisibility(View.GONE);
		}
		if (expandableListViewContent.isGroupExpanded(groupPos)) {
			imgExpand.setBackgroundResource(R.drawable.icon_default_packup);
		} else {
			imgExpand.setBackgroundResource(R.drawable.icon_default_unfold);
		}
		linearTitle.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				if (expandableListViewContent.isGroupExpanded(groupPos)) {
					imgExpand
							.setBackgroundResource(R.drawable.icon_default_unfold);
					expandableListViewContent.collapseGroup(groupPos);
					expandableListViewContent.setSelectedGroup(groupPos);
				} else {
					imgExpand
							.setBackgroundResource(R.drawable.icon_default_packup);
					expandableListViewContent.expandGroup(groupPos);
				}

			}
		});

	}

	@Override
	public void onScrollStateChanged(AbsListView view, int scrollState) {

	}

	private Dialog filterDialog;

	private int rangqiuType;
	private ArrayList<String> listSelectedLeagueNmae = new ArrayList<String>();
	// private ArrayList<RadioButton> listRbRangqiu = new
	// ArrayList<RadioButton>();
	// private ArrayList<RadioButton> listRbPeilv = new
	// ArrayList<RadioButton>();

	private HashSet<String> selectedLeagues = new HashSet<String>();

	private ScrollView scrollViewFilter;
	private Button btnSelectAll;
	private Button btnSelectInverse;
	private GridViewNoScroll gvLeagues;
	private Button btnFilterSubmit;
	private Button btnFilterCancel;

	private FilterAdapter filterAdapter;
	@SuppressWarnings("unused")
	private boolean filterOutdated;
	private RadioGroup rgRangqiu;

	/** 弹出筛选dialog */
	private void showDialogFilter() {

		if (filterDialog == null) {
			filterDialog = new Dialog(context, R.style.dialogNoFloating);
			filterDialog.getWindow().setContentView(
					R.layout.sportteryfootball_filter_page);

			filterAdapter = new FilterAdapter(context);

			gvLeagues = (GridViewNoScroll) filterDialog
					.findViewById(R.id.gv_filter_matchs);
			gvLeagues.setAdapter(filterAdapter);
			btnFilterSubmit = (Button) filterDialog
					.findViewById(R.id.btn_filter_submit);
			btnFilterCancel = (Button) filterDialog
					.findViewById(R.id.btn_filter_cancel);
			btnSelectAll = (Button) filterDialog
					.findViewById(R.id.btn_filter_select_all);
			btnSelectInverse = (Button) filterDialog
					.findViewById(R.id.btn_filter_select_inverse);
			rgRangqiu = (RadioGroup) filterDialog
					.findViewById(R.id.rg_filter_rangqiu);

			btnSelectAll.setOnClickListener(new View.OnClickListener() {

				@Override
				public void onClick(View v) {
					filterAdapter.selectAll();
					filterAdapter.notifyDataSetChanged();
				}
			});

			btnSelectInverse.setOnClickListener(new View.OnClickListener() {

				@Override
				public void onClick(View v) {
					filterAdapter.selectInverse();
					filterAdapter.notifyDataSetChanged();
				}
			});

			btnFilterCancel.setOnClickListener(new View.OnClickListener() {

				@Override
				public void onClick(View v) {
					filterDialog.dismiss();
				}
			});

			btnFilterSubmit.setOnClickListener(new View.OnClickListener() {

				@Override
				public void onClick(View v) {
					selectedLeagues.clear();
					selectedLeagues.addAll(filterAdapter.getSelectedLeagues());
					switch (rgRangqiu.getCheckedRadioButtonId()) {
					case R.id.rb_filter_rangqiu_all:
						rangqiuType = 0;
						break;
					case R.id.rb_filter_rangqiu_rang:
						rangqiuType = 1;
						break;
					case R.id.rb_filter_rangqiu_burang:
						rangqiuType = 2;
						break;
					default:
						break;
					}
					filterOutdated = false;
					fliterButton
							.setBackgroundResource(R.drawable.btn_lotterychoose_filtered_style);
					updateAllList();
					updateRecommendList();

				}

			});
		}
		filterAdapter
				.setAllLeagues(sportteryFootballNoFilterAgainstInfoCommunicater
						.getLeagueNames());
		filterAdapter.setSelectedLeagues(selectedLeagues);

		switch (rangqiuType) {
		case 0:
			rgRangqiu.check(R.id.rb_filter_rangqiu_all);
			break;
		case 1:
			rgRangqiu.check(R.id.rb_filter_rangqiu_rang);
			break;
		case 2:
			rgRangqiu.check(R.id.rb_filter_rangqiu_burang);
			break;
		}

		filterAdapter.setSelectedLeagues(selectedLeagues);
		filterAdapter.notifyDataSetChanged();
		//
		// OnClickListener onClickListener = new OnClickListener() {
		//
		// @Override
		// public void onClick(View v) {
		//
		// switch (v.getId()) {
		// case R.id.sportteryfootballfilterpage_btn_cancel:
		// filterDialog.dismiss();
		// break;
		//
		// case R.id.sportteryfootballfilterpage_btn_submit:
		// EDebug.o(SportteryFootballChooseList.this, "完成按下");
		// listSelectedLeagueNmae.clear();
		// for (int i = 0; i < saishiItemCheckedList.size(); i++) {
		// SportteryFootballLotteryInfo
		// .getSportteryFootballLotteryInfo()
		// .getSimpleLeagueList().get(i)
		// .put(IS_CHECKED, saishiItemCheckedList.get(i));
		// if (saishiItemCheckedList.get(i)) {
		// listSelectedLeagueNmae
		// .add((String) SportteryFootballLotteryInfo
		// .getSportteryFootballLotteryInfo()
		// .getSimpleLeagueList().get(i)
		// .get(NAME));
		// EDebug.o(
		// SportteryFootballChooseList.this,
		// "筛选球队"
		// + (String) SportteryFootballLotteryInfo
		// .getSportteryFootballLotteryInfo()
		// .getSimpleLeagueList()
		// .get(i).get(NAME));
		// }
		// }
		// peilvType = peilvType_;
		// rangqiuType = rangqiuType_;
		// updateListExpandadble(listContent, false);
		// sportteryFootballExpandableListAdapter
		// .notifyDataSetChanged();
		// filterDialog.dismiss();
		//
		// Message msgToGroup = SportteryFootballAgp.handlerSportteryFootballAgp
		// .obtainMessage(SportteryFootballAgp.SHOW_FILTER,
		// null);
		// SportteryFootballAgp.handlerSportteryFootballAgp
		// .sendMessage(msgToGroup);
		// break;
		//
		// case R.id.sportteryfootballfilterpage_btn_quanxuan:
		// EDebug.o(SportteryFootballChooseList.this,
		// "do quanxuan !!!!!");
		// for (int i = 0; i < alViewsList.size(); i++) {
		// View view = alViewsList.get(i);
		// CheckBox cb = (CheckBox) view
		// .findViewById(R.id.sportteryfootballdialogsaishiitem_cbx_item);
		// cb.setChecked(true);
		// }
		// break;
		//
		// case R.id.sportteryfootballfilterpage_btn_fanxuan:
		// EDebug.o(
		// SportteryFootballChooseList.this,
		// "saishiItemCheckedList size is "
		// + saishiItemCheckedList.size()
		// + "alViewsList size is "
		// + alViewsList.size());
		// for (int i = 0; i < alViewsList.size(); i++) {
		// View view = alViewsList.get(i);
		// CheckBox cb = (CheckBox) view
		// .findViewById(R.id.sportteryfootballdialogsaishiitem_cbx_item);
		// boolean b = cb.isChecked();
		// cb.setChecked(!b);
		// }
		// break;
		//
		// default:
		// break;
		// }
		// }
		// };
		//
		// android.widget.RadioGroup.OnCheckedChangeListener
		// onCheckedChangeListenerRangqiu = new
		// RadioGroup.OnCheckedChangeListener() {
		//
		// @Override
		// public void onCheckedChanged(RadioGroup group, int checkedId) {
		//
		// switch (checkedId) {
		// case R.id.sportteryfootballfilterpage_rb_rangqiuA:
		// rangqiuType_ = 0;
		// break;
		//
		// case R.id.sportteryfootballfilterpage_rb_rangqiu:
		// rangqiuType_ = 1;
		// break;
		//
		// case R.id.sportteryfootballfilterpage_rb_unRangqiu:
		// rangqiuType_ = 2;
		// break;
		//
		// default:
		// break;
		// }
		//
		// }
		// };
		// android.widget.RadioGroup.OnCheckedChangeListener
		// onCheckedChangeListenerPeilv = new
		// RadioGroup.OnCheckedChangeListener() {
		//
		// @Override
		// public void onCheckedChanged(RadioGroup group, int checkedId) {
		//
		// switch (checkedId) {
		// case R.id.sportteryfootballfilterpage_rb_peilvA:
		// peilvType_ = 0;
		// break;
		//
		// case R.id.sportteryfootballfilterpage_rb_peilvL:
		// peilvType_ = 1;
		// break;
		//
		// case R.id.sportteryfootballfilterpage_rb_peilvM:
		// peilvType_ = 2;
		// break;
		//
		// case R.id.sportteryfootballfilterpage_rb_peilvH:
		// peilvType_ = 3;
		// break;
		// default:
		// break;
		// }
		//
		// }
		// };
		// ImageButton btnCancel = (ImageButton) filterDialog.getWindow()
		// .findViewById(R.id.sportteryfootballfilterpage_btn_cancel);
		// btnCancel.setOnClickListener(onClickListener);
		// Button btnSubmit = (Button) filterDialog.getWindow().findViewById(
		// R.id.sportteryfootballfilterpage_btn_submit);
		// btnSubmit.setOnClickListener(onClickListener);
		// Button btnQuanxuan = (Button) filterDialog.getWindow().findViewById(
		// R.id.sportteryfootballfilterpage_btn_quanxuan);
		// btnQuanxuan.setOnClickListener(onClickListener);
		// Button btnFanxuan = (Button) filterDialog.getWindow().findViewById(
		// R.id.sportteryfootballfilterpage_btn_fanxuan);
		// btnFanxuan.setOnClickListener(onClickListener);
		// RadioGroup rgRangqiu = (RadioGroup) filterDialog.getWindow()
		// .findViewById(R.id.sportteryfootballfilterpage_rg_rangqiu);
		// rgRangqiu.setOnCheckedChangeListener(onCheckedChangeListenerRangqiu);
		// RadioGroup rgPeilv = (RadioGroup) filterDialog.getWindow()
		// .findViewById(R.id.sportteryfootballfilterpage_rg_peilv);
		// rgPeilv.setOnCheckedChangeListener(onCheckedChangeListenerPeilv);
		//
		// filterDialog.setOnDismissListener(new Dialog.OnDismissListener() {
		//
		// @Override
		// public void onDismiss(DialogInterface dialog) {
		//
		// if (imageListCache != null) {
		// imageListCache.stop();
		// }
		// }
		// });
		//
		// if (listImageCache.size() == saishiItemCheckedList.size()) {
		// Message msg = handlerChoosePage.obtainMessage(
		// GET_IMAGECACHE_SUCCEED, null);
		// handlerChoosePage.sendMessage(msg);
		// }

		filterDialog.show();
	}

	/**
	 * @title updateAllList
	 * @description 更新投注的列表
	 */
	protected void updateAllList() {
		updateListExpandadble(listContent, false);
		sportteryFootballExpandableListAdapter.notifyDataSetChanged();
		filterDialog.dismiss();
	}

	/**
	 * @title updateRecommendList
	 * @description 更新推荐的列表
	 */
	protected void updateRecommendList() {
		updateListExpandadble(listContent, false);
		sportteryFootballExpandableListAdapter.notifyDataSetChanged();
		filterDialog.dismiss();
	}

	@Override
	public void setSportteryBuyLotteryPage(SportteryBuyLottery buyLotteryPage) {
		this.buyLotteryPage = buyLotteryPage;
	}

}
